﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="clr-namespace:TeamProjectManager.Shell.Infrastructure"
    xmlns:c="clr-namespace:TeamProjectManager.Common.Converters;assembly=TeamProjectManager.Common">

    <SolidColorBrush x:Key="AccentBrush" Color="#F09609" />
    <SolidColorBrush x:Key="LinkBrush" Color="#2470E3" />
    <SolidColorBrush x:Key="DisabledLinkBrush" Color="DarkGray" />
    <SolidColorBrush x:Key="UserMessageFontBrush" Color="Gray" />
    <SolidColorBrush x:Key="ErrorForegroundBrush" Color="#E51400" />
    <SolidColorBrush x:Key="WarningForegroundBrush" Color="Orange" />
    <SolidColorBrush x:Key="SuccessForegroundBrush" Color="#50DD50" />
    <SolidColorBrush x:Key="BorderBrush" Color="#FF747474" />
    <SolidColorBrush x:Key="SelectedTabTextBrush" Color="Black" />
    <SolidColorBrush x:Key="UnSelectedTabTextBrush" Color="DarkGray" />
    <SolidColorBrush x:Key="ActiveTabTextBrush" Color="Gray" />

    <c:EnumToBooleanConverter x:Key="enumConverter" />
    <c:CaseConverter x:Key="caseConverter" />
    <c:SingleLineConverter x:Key="singleLineConverter" />
    <c:InverseBooleanConverter x:Key="inverseBooleanConverter" />
    <i:HelpContentConverter x:Key="helpContentConverter" />

    <Style TargetType="{x:Type Grid}" />
    <Style TargetType="{x:Type ProgressBar}" />

    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="FontFamily" Value="Segoe UI,Tahoma,Verdana,Helvetica,Sans-Serif" />
    </Style>

    <LinearGradientBrush x:Key="ResizeGripperForeground" EndPoint="1,0.75" StartPoint="0,0.25">
        <GradientStop Color="#FFFFFF" Offset="0.3"/>
        <GradientStop Color="#BBC5D7" Offset="0.75"/>
        <GradientStop Color="#6D83A9" Offset="1"/>
    </LinearGradientBrush>
    <Style x:Key="ResizeGripThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                        <Path HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Data="M 9,0 L 11,0 L 11,11 L 0,11 L 0,9 L 3,9 L 3,6 L 6,6 L 6,3 L 9,3 z">
                            <Path.Fill>
                                <DrawingBrush TileMode="Tile" Viewbox="0,0,3,3" ViewboxUnits="Absolute" Viewport="0,0,3,3" ViewportUnits="Absolute">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="{StaticResource ResizeGripperForeground}" Geometry="M 0,0 L 2,0 L 2,2 L 0,2 z "/>
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Path.Fill>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Label}" x:Key="SeparatingLabel">
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Padding" Value="0,10,0,5" />
        <Setter Property="Foreground" Value="{DynamicResource FontColor}" />
    </Style>

    <ControlTemplate x:Key="HorizontalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
        <Grid x:Name="Bg" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                <ColumnDefinition Width="1E-05*"/>
                <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
            </Grid.ColumnDefinitions>
            <RepeatButton IsEnabled="{TemplateBinding IsMouseOver}" Command="ScrollBar.PageLeftCommand">
                <RepeatButton.Style>
                    <Style TargetType="{x:Type RepeatButton}">
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="Focusable" Value="False"/>
                        <Setter Property="IsTabStop" Value="False"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <Border Background="{x:Null}" Height="18" Width="18" >
                                        <Path Data=" M 8 15 L 8 3 L 2 9 Z" Fill="{StaticResource AccentBrush}" />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </RepeatButton.Style>
            </RepeatButton>
            <RepeatButton IsEnabled="{TemplateBinding IsMouseOver}" Command="ScrollBar.PageRightCommand" Grid.Column="2">
                <RepeatButton.Style>
                    <Style TargetType="{x:Type RepeatButton}">
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="Focusable" Value="False"/>
                        <Setter Property="IsTabStop" Value="False"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <Border Background="{x:Null}" Height="18" Width="18" >
                                        <Path Data=" M 9 15 L 9 3 L 15 9 Z" Fill="{StaticResource AccentBrush}" />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </RepeatButton.Style>
            </RepeatButton>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" TargetName="Bg" Value="#FFF4F4F4"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="ScrollViewerTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid x:Name="Grid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Rectangle x:Name="Corner" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Column="1" Grid.Row="1"/>
            <ScrollBar x:Name="PART_HorizontalScrollBar" Cursor="Arrow" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="0" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" AutomationProperties.AutomationId="HorizontalScrollBar" Template="{DynamicResource HorizontalScrollBarTemplate}"/>
            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Margin="15,2,15,0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Grid.Column="0" Grid.Row="0" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/>
        </Grid>
    </ControlTemplate>
    <ControlTemplate x:Key="ScrollableTabControlTemplate" TargetType="{x:Type TabControl}">
        <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="ColumnDefinition0"/>
                <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                <RowDefinition x:Name="RowDefinition1" Height="*"/>
            </Grid.RowDefinitions>
            <ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" Template="{DynamicResource ScrollViewerTemplate}">
                <Border Grid.Row="0" BorderBrush="{StaticResource AccentBrush}" BorderThickness="0,0,0,1" Margin="0,0,0,5">
                    <TabPanel x:Name="HeaderPanel" IsItemsHost="True" Panel.ZIndex="1" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabIndex="1"/>
                </Border>
            </ScrollViewer>
            <Border x:Name="ContentPanel" BorderThickness="1" Grid.Column="0" Grid.Row="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                <ContentPresenter x:Name="PART_SelectedContentHost" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding SelectedContent}" ContentSource="SelectedContent" ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" ContentTemplate="{TemplateBinding SelectedContentTemplate}"/>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="TabStripPlacement" Value="Bottom">
                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Left">
                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Right">
                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style TargetType="{x:Type TabControl}">
        <Setter Property="Template" Value="{StaticResource ScrollableTabControlTemplate}" />
    </Style>

    <Style x:Key="ShellTabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabControl">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" BorderBrush="{StaticResource AccentBrush}" BorderThickness="0,0,0,1" Margin="0,0,0,5">
                            <TabPanel IsItemsHost="true"/>
                        </Border>
                        <ContentPresenter Grid.Row="1" ContentSource="SelectedContent" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <ContentControl Margin="5" x:Name="tabHeader" Foreground="{StaticResource UnSelectedTabTextBrush}" FontWeight="DemiBold">
                        <TextBlock Text="{TemplateBinding Header, Converter={StaticResource caseConverter}}" />
                    </ContentControl>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource SelectedTabTextBrush}" TargetName="tabHeader" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Border.IsMouseOver" Value="True"/>
                                <Condition Property="IsSelected" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Foreground" Value="{StaticResource ActiveTabTextBrush}" TargetName="tabHeader" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Tab Items With Headers -->
    <Style x:Key="ShellTabItemStyle" TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
        <Setter Property="Header" Value="{Binding Path=Content.DataContext.Info.Title, RelativeSource={RelativeSource Self}}" />
        <Setter Property="FontSize" Value="14" />
    </Style>

    <Style TargetType="{x:Type Expander}">
        <Setter Property="IsExpanded" Value="True" />
    </Style>

    <Style TargetType="{x:Type Button}">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Padding" Value="10,2,10,2" />
    </Style>

    <Style x:Key="CheckedListBoxStyle" TargetType="{x:Type ListBox}">
        <!-- Remove the white background for disabled list boxes -->
        <!-- See http://stackoverflow.com/questions/2594714/change-background-color-of-disabled-listbox-in-windows-classic-theme -->
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
            <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="Transparent"/>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
        </Style.Resources>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" IsEnabled="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsEnabled}" Content="{Binding}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Hyperlink}">
        <Setter Property="Foreground" Value="{StaticResource LinkBrush}" />
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledLinkBrush}" />
                <Setter Property="TextDecorations" Value="None" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>